package com.demo2do.fms.scheduler.entity;

import java.util.Date;

import org.apache.commons.lang3.StringUtils;

import com.demo2do.fms.entity.vehicle.source.LockType;


/**
 *
 * @author Ark
 *
 */
public class RemoteTransMeans {

	/** id */
	private Long id;
	
	/** 车辆代码 */
	private String code;
	
	/** 车辆类型（是否是特殊车辆） */
	private Integer specialTrans;
	
	/** 锁定状态 */
	private Integer locking;
	
	/** 锁定类型 */
	private String lockType;

	/** 锁定/解锁操作人 */
	private Long lockUnlockOperator;
	
	/** 解锁/锁定时间 */
	private Date unlockDate;
	
	/** 备注 */
	private String mark;
	
	/** 最后操作人 */
	private Long lastOperator;
	
	/** 最后操作时间 */
	private Date lastModified; 
	
	/**
	 * The default constructor
	 */
	public RemoteTransMeans() {
	}
	
	/**
	 * @return
	 */
	public boolean isAvaliable() {
    	
    	if (this.specialTrans == null) {
    		return false;
    	}
    	
        return (this.specialTrans.intValue() == 0) || (this.specialTrans.intValue() == 2);
        
    }
	
	/**
	 * 是否是调度异常锁定
	 * 
	 * @return
	 */
	public boolean isShipmentException() {
		
		if (StringUtils.isEmpty(lockType)) {
			return false;
		}
		
		return StringUtils.equals("01", lockType);
		
	}
	
	/**
	 * @return
	 */
	public boolean isLock() {
        return locking.intValue() == 1;
    }
	
	/**
	 * @param type
	 * @return
	 */
	public RemoteTransMeans lock(LockType type, Long operator) {
        this.locking = 1;
        this.lockType = type.getCode();
        this.lockUnlockOperator = operator;
        this.unlockDate = new Date();
        this.lastOperator = operator;
        this.lastModified = new Date();
        return this;
    }
	
	/**
	 * @return
	 */
	public RemoteTransMeans unlock(Long operator) {
        this.locking = 0;
        this.lockType = null;
        this.lockUnlockOperator = operator;
        this.unlockDate = new Date();
        this.lastOperator = operator;
        this.lastModified = new Date();
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the code
     */
    public String getCode() {
        return code;
    }

    /**
     * @return the specialTrans
     */
    public Integer getSpecialTrans() {
        return specialTrans;
    }

    /**
     * @return the locking
     */
    public Integer getLocking() {
        return locking;
    }

    /**
     * @return the lockType
     */
    public String getLockType() {
        return lockType;
    }

    /**
     * @return the lockUnlockOperator
     */
    public Long getLockUnlockOperator() {
        return lockUnlockOperator;
    }

    /**
     * @return the unlockDate
     */
    public Date getUnlockDate() {
        return unlockDate;
    }

    /**
     * @return the mark
     */
    public String getMark() {
        return mark;
    }

    /**
     * @return the lastOperator
     */
    public Long getLastOperator() {
        return lastOperator;
    }

    /**
     * @return the lastModified
     */
    public Date getLastModified() {
        return lastModified;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param code the code to set
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * @param specialTrans the specialTrans to set
     */
    public void setSpecialTrans(Integer specialTrans) {
        this.specialTrans = specialTrans;
    }

    /**
     * @param locking the locking to set
     */
    public void setLocking(Integer locking) {
        this.locking = locking;
    }

    /**
     * @param lockType the lockType to set
     */
    public void setLockType(String lockType) {
        this.lockType = lockType;
    }

    /**
     * @param lockUnlockOperator the lockUnlockOperator to set
     */
    public void setLockUnlockOperator(Long lockUnlockOperator) {
        this.lockUnlockOperator = lockUnlockOperator;
    }

    /**
     * @param unlockDate the unlockDate to set
     */
    public void setUnlockDate(Date unlockDate) {
        this.unlockDate = unlockDate;
    }

    /**
     * @param mark the mark to set
     */
    public void setMark(String mark) {
        this.mark = mark;
    }

    /**
     * @param lastOperator the lastOperator to set
     */
    public void setLastOperator(Long lastOperator) {
        this.lastOperator = lastOperator;
    }

    /**
     * @param lastModified the lastModified to set
     */
    public void setLastModified(Date lastModified) {
        this.lastModified = lastModified;
    }
	
}
